﻿<%@ Control Language="C#" ClassName="PaymentsILM" Inherits="Dimok.Web.UI.TableControl" %>
<script runat="server">
	public int LoanID { get { return (int)Lib.GetProperty(Parent, "LoanID"); } }
	protected override void OnInit(EventArgs e) {
		base.OnInit(e);
		grv.RowInserting += new EventHandler<GridViewInsertEventArgs>(grv_RowInserting);
	}

	void grv_RowInserting(object sender, GridViewInsertEventArgs e) {
		e.InsertingValues["LoanID"] = LoanID;
	}
	
</script>
<asp:UpdatePanel ID="upPayments" UpdateMode="Always" runat="server">
	<ContentTemplate>
	<UI:GridViewMB ID="grv" runat="server" AutoGenerateColumns="False"
		AllowSorting="true" ShowFooter="true"
		DataKeyNames="ID" DataSourceID="ds">
	<Columns>
		<asp:TemplateField HeaderText="LoanID" SortExpression="LoanID">
			<ItemTemplate><%#Eval("LoanID")%></ItemTemplate>
		</asp:TemplateField>
		<asp:BoundField DataField="PaymentNumber" HeaderText="Pmt#" SortExpression="PaymentNumber" ItemStyle-HorizontalAlign="Right" />
		<asp:TemplateField HeaderText="Amount" SortExpression="Amount" ItemStyle-HorizontalAlign="Right">
			<ItemTemplate><%#Eval("Amount")%></ItemTemplate>
			<FooterTemplate><asp:TextBox ID="Amount" runat="server" /></FooterTemplate>
		</asp:TemplateField>
		<asp:TemplateField HeaderText="DatePaid" SortExpression="DatePaid">
			<ItemTemplate><%#Eval("DatePaid","{0:MM/dd/yyyy}")%></ItemTemplate>
			<FooterTemplate><asp:TextBox ID="DatePaid" runat="server" /></FooterTemplate>
		</asp:TemplateField>
		
		<asp:BoundField DataField="DateScheduled" DataFormatString="{0:MM/dd/yyyy}" HeaderText="DateSched"	SortExpression="DateScheduled" />
		<asp:BoundField DataField="DPD" HeaderText="DPD"	SortExpression="DPD" />
		<asp:BoundField DataField="StatusDate" HeaderText="StatusDate" SortExpression="StatusDate" DataFormatString="{0:MM/dd/yyyy}" />
		<asp:BoundField DataField="Interest" HeaderText="Interest" SortExpression="Interest" ItemStyle-HorizontalAlign="Right" />
		<asp:BoundField DataField="LateFee" HeaderText="LateFee" SortExpression="LateFee" ItemStyle-HorizontalAlign="Right" />
		<asp:BoundField DataField="PrincipalBalance" HeaderText="PrnBal" SortExpression="PrincipalBalance" ItemStyle-HorizontalAlign="Right" />
		<asp:BoundField DataField="ExpectedBalance" HeaderText="ExpBal" SortExpression="ExpectedBalanceBalance" ItemStyle-HorizontalAlign="Right" />
		<asp:BoundField DataField="PaymentBalance" HeaderText="PmtBal" SortExpression="PaymentBalance" ItemStyle-HorizontalAlign="Right" />
		<asp:BoundField DataField="DateNext" DataFormatString="{0:MM/dd/yyyy}" HeaderText="DateNext" SortExpression="DateNext" />
		<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
		<asp:BoundField DataField="StatusUser" HeaderText="User" SortExpression="StatusUser" />
		<asp:BoundField DataField="IntAddOn" HeaderText="IntAddOn" SortExpression="IntAddOn" />
	</Columns>
</UI:GridViewMB>
<fieldset style="width:1px"><legend><label>Amortization</label></legend>
<UI:GridViewEx DataSourceID="dsSchedule" AllowSorting="true" runat="server" />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>

<DS:PaymentsMBDataSource ID="ds" runat="server">
	<SelectParameters>
		<asp:ControlParameter PropertyName="Page.LoanID" Name="LoanID" Type="Int32" />
	</SelectParameters>
</DS:PaymentsMBDataSource>
<DS:FunctionDataSource ID="dsSchedule" SelectViewName="PaymentScheduleByLoanID(@ID)" runat="server">
	<SelectParameters>
		<asp:ControlParameter PropertyName="Page.LoanID" Name="ID" Type="Int32" />
	</SelectParameters>
</DS:FunctionDataSource>
